package com.toulezu.test.freemarker;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.ckjava.xutils.EncodesUtils;

/**
 * 无需实现任何接口来实现自定义方法
 */
public class Custom {

    public int add(int a, int b) {
        return a + b;
    }

    public String base64(String data) {
        try {
            return EncodesUtils.encodeBase64(data);
        } catch (Exception e) {
            return null;
        }

    }

	public String toJSONString(String data) {
		try {
			System.out.println("data:" + data);
			return JSON.toJSONString(JSONObject.parseObject(data, Feature.OrderedField));
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
